﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="MenuMaintain.aspx.cs" Inherits="PMS.Web.MenuMaintain" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <link rel="stylesheet" href="tipswindown/tipswindown.css" type="text/css" media="all" />
    <script type="text/javascript" src="tipswindown/tipswindown.js"></script>
    <script type="text/javascript">
        //菜单
        function editMenu(roleID) {
            var parentID = $("#hid_parentID").val();
            var title = "添加菜单";
            if (roleID != 0) {
                title = "编辑菜单";
            }
            tipsWindown(title, "iframe:AddMenu.aspx?parentID=" + parentID + "&roleID=" + roleID, "200", "100", "true", "", "true", "leotheme");
        }

        //用户
        function editUser(id) {
            var parentID = $("#hid_parentID").val();
            var title = "添加用户";
            if (id != 0) {
                title = "编辑用户";
            }
            tipsWindown(title, "iframe:AddUser.aspx?roleID=" + parentID + "&userID=" + id, "230", "120", "true", "", "true", "leotheme");
        }

        function closeWin() {
            window.location.href = window.location.href;
        }

        function closeUserWin() {
            $("#windown-close").click();
            var roleid = $("#hid_parentID").val();
            LoadUserList(roleid);
        }

        //删除
        function deleteMenu(id) {
            if (confirm('确定删除?')) {
                $.post("Menu.ashx", { action: "DeleteMenu", roleID: id }, function (data) {
                    if (data == "0") {
                        $("#MainContent_btn_ClearCache").click();
                        window.location.href = window.location.href;
                    }
                    else {
                        alert("删除失败");
                    }
                });
            }
        }


        //删除
        function deleteUser(id) {
            if (confirm('确定删除?')) {
                $.post("UserMaintain.ashx", { action: "DeleteUser", id: id }, function (data) {
                    if (data == "0") {
                        $("#MainContent_btn_ClearCache").click();
                        window.location.href = window.location.href;
                    }
                    else {
                        alert("删除失败");
                    }
                });
            }
        }

        //母版页调用方法
        function GetList(roleid) {
            $("#hid_parentID").val(roleid);
            LoadMenuList(roleid);
            LoadUserList(roleid);
        }

        function LoadUserList(roleID) {
            $.post("UserMaintain.ashx", { action: "GetList", roleID: roleID }, function (data) {
                $("#userMaintain").html(data);
            });
        }

        function LoadMenuList(roleID) {
            $.post("Menu.ashx", { action: "GetList", parentID: roleID }, function (data) {
                $("#menuMaintain").html(data);
            });
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:Button ID="btn_ClearCache" runat="server" Text="Clear" OnClick="btn_ClearCache_Click"
        Style="display: none;" />
    <input type="hidden" id="hid_parentID" value="0" />
    <table width="99%">
        <tr>
            <td>
                <input type="button" value="添加菜单" class="BlueButton_Min" onclick="editMenu(0)" />
            </td>
        </tr>
        <tr>
            <td id="menuMaintain">
            </td>
        </tr>
    </table>
    <img src="image/mainpage_line.jpg">
    <table width="99%">
        <tr>
            <td>
                <input type="button" value="添加用户" class="BlueButton_Min" onclick="editUser(0)" />
            </td>
        </tr>
        <tr>
            <td id="userMaintain">
            </td>
        </tr>
    </table>
</asp:Content>
